<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateRedRecordsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('red_records', function (Blueprint $table) {
            $table->id();
            $table->bigInteger('member_id')->unsigned()->comment('用户id');
            $table->integer('red_id')->unsigned()->comment('红包id');
            $table->unique(['member_id','red_id']);
            $table->integer('money')->unsigned()->comment('红包金额');
            $table->integer('pid')->unsigned()->default(0)->comment('记录父级id(0=顶级，其他=父级id)');
            $table->tinyInteger('go_to')->unsigned()->default(1)->comment('红包金额存入目标（1=余额，2=微信钱包）');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('red_records');
    }
}
